<template>
  <el-form class="add-event-number-day-exists" v-if="wbData">
    <switch-normal label="全局计数" v-model="wbData.isGlobal"  @change="onUpdateWbComponent"></switch-normal>
    <input-normal label="关联组件id" placeholder="$id$" v-model="wbData.relateCompId"  @change="onUpdateWbComponent"></input-normal>
  </el-form>
</template>

<script setup lang="ts">
import { useWebControlsStore } from '@/store/web/controls'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()

let wbData_: any
const wbData = computed(() => {
  try {
    wbData_ = useWebControls.currentControls![event.controlId] && useWebControls.currentControls![event.controlId].data
  } catch (error) {
    console.log("controlData.data null")
  }
  return wbData_
})
const onUpdateWbComponent = () => {
  useWebControls.updateWbComponent({ controlId: event.controlId, data: wbData_ })
}
</script>